package _08作业.t1;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class UDPReceviver {
    public static void main(String[] args) throws IOException {
        //1. 创建接收端
        DatagramSocket socket = new DatagramSocket(9999);

        //2.创建接收数据的数组
        byte[] bytes = new byte[1024];
        DatagramPacket p = new DatagramPacket(bytes,bytes.length);
        socket.receive(p);
        //3.打印数据到控制台
        System.out.println(new String(bytes,0,bytes.length));
        socket.close();

    }
}
